from rich.console import Console
from rich import print

# console = Console() 
res  = []

def permute( nums):
    tarck = []
    backtrack(nums,tarck)
    return  res

def backtrack(nums,track):
    if (len(track) == len(nums) ):
        res.append(track.copy())
        # console.log( 'nums长度和track长度一致'  , style="bold red underline")
        # print('当前res是: '+ str(res))
        return res
 
    for i in nums:
        if i in track:
            continue
        track.append(i)
        
        backtrack(nums,track)
        track.pop()
        
        
res  = permute([1,2,3])     
# console.log( res  , style="bold green ")
# 输出结果:   [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]    
